<!DOCTYPE html>
<html>

	<head>
		<title>消息界面</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
		<script src="/js/jquery/jquery.min.js"></script>
		<script src="/js/bootstrap/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
		<link rel="stylesheet" href="/css/reset.css"/>
		<link rel="stylesheet" href="/css/travelContent.css"/>
		<link rel="stylesheet" href="/js/plugins/comments-master/css/index.css">
		<link rel="stylesheet" href="/js/plugins/dialog/dialog.css">
		<script src="/js/plugins/jrender/jrender.js"></script>
		<script src="/js/common.js"></script>
		<script src="/js/plugins/dialog/dialog.min.js"></script>

		<script>
			$(function () {
                //拿到当前登录的用户
                //拿到当前登录的用户，要求必须登录之后才能评论
                var currentuser ;
                currentuser = JSON.parse(sessionStorage.getItem("user"));

                //拿到当前用户的id,查出自己所有的系统通知信息
				$.get("/users/"+currentuser.id+"/systemmessages",function (data) {
                    //渲染数据
                    $("#comments").renderValues({list:data}, {
                        messageId:function (ele, value) {
                            $(ele).attr("data-id",value);
                        }
                    })

                })

                //给已读按钮绑定点击事件
                $("#comments").on("click","#deleteBtn",function () {
                    //拿到按钮上面的Id,删除我的信息表中的数据
					$.ajax({
						url:"/systemmessage/"+$(this).data("id"),
						data:{'userId':currentuser.id},
						type:"DELETE"
					})
                    window.location.reload();
                })

            })



		</script>
	</head>

	<body>
		<div class="search-head">
			<div class="row nav-search">
				<div class="col">
					<a href="javascript:history.go(-1);">
						<span><i class="fa fa-chevron-left" ></i></span>
					</a>
				</div>
				<div class="col">
					<span>我的消息界面</span>
				</div>
				<div class="col"></div>
			</div>
		</div>
		<div class="row dynamic " id="comments">
			<div class="col" >
				<div class="Marquee">
					<div class="d-flex" >
						<dl class="itemList" render-loop="list">
							<dd>
								<p render-html="list.content"></p>
								<p>-- 骡窝官方</p>
								<p render-html="list.releaseTime"></p>
								<input type="button" id="deleteBtn" render-key="list.id" render-fun="messageId" value="已读">
							</dd>
						</dl>

					</div>

				</div>
			</div>
		</div>


	</body>

</html>